import javax.rmi.CORBA.StubDelegate;

class Student {
    public String name;
    private int age;
    public static String classRoom = "2022";


    public void doClass() {
        System.out.println(name+"上课！");
    }
    public static void func() {

//        System.out.println(this.name);
//        System.out.println(name);

//        Student student = new Student("zhangsan",18);
//        System.out.println(student.name);
//
//        System.out.println("staticFunc()");

        {
            //这块代码的执行，不需要条件
            System.out.println("定义在方法内部的代码块！普通代码块！");
        }
    }
    public static int size;

    public Student(String name, int age, int si) {
        this.name = name;
        this.age = age;
        size = si;
    }
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("带有2个参数的构造方法！");
    }
    {
        name = "caocao";
        System.out.println("非静态代码块/实例代码块/构造代码块！--->初始化非静态的数据成员");
    }
    static {
        System.out.println("静态代码块 -->初始化静态的数据成员/ 提前准备一些数据");
    }

    public static int getSize() {
        return size;
    }

    public static void setSize(int size) {
        Student.size = size;
    }
}
public class Test2 {
    public static void main1(String[] args) {
        Student student1 = new Student("gaobo",10);
    }

    public static void main2(String[] args) {
        Student student1 = null;
        //System.out.println(student1.name);//报错，空指针异常
        System.out.println(student1.classRoom);

        System.out.println(Student.classRoom);

    }

    public static void main3(String[] args) {
        Student student1 = new Student("zhangsan",10);
        student1.doClass();
        student1.func();
    }

    public static void main4(String[] args) {
        Student.func();//静态成员方法是不依赖于对象的
    }
    public void mainStaticFunc() {

    }
    public static void main5(String[] args) {
//        Test2 test2 = new Test2();
//        test2.mainStaticFunc();
        //mainStaticFunc();
    }

    public static void main6(String[] args) {
        Student.func();
    }

    public static void main(String[] args) {
        Student student1 = new Student("zahngsan",10);
        //System.out.println(student1.name);

    }

}
